package com.zgjkhis.modules.system.service.impl;

import com.github.pagehelper.PageInfo;
import com.zgjkhis.common.service.impl.BaseServiceImpl;
import com.zgjkhis.common.utils.QueryHelpPlus;
import com.zgjkhis.domain.PageResult;
import com.zgjkhis.modules.system.domain.Schedule;
import com.zgjkhis.modules.system.service.ScheduleService;
import com.zgjkhis.modules.system.service.dto.ScheduleDto;
import com.zgjkhis.modules.system.service.dto.ScheduleQueryCriteria;
import com.zgjkhis.modules.system.service.mapper.ScheduleMapper;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @date 2020-05-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ScheduleServiceImpl extends BaseServiceImpl<ScheduleMapper, Schedule> implements ScheduleService {

    @Override
    public PageResult<ScheduleDto> queryAll(ScheduleQueryCriteria criteria, Pageable pageable) {
        getPage(pageable);
        PageInfo<Schedule> page = new PageInfo<>(baseMapper.findAllByPageable(criteria));
        return PageResult.data(page, ScheduleDto.class);
    }


    @Override
    public List<Schedule> queryAll(ScheduleQueryCriteria criteria){
        return baseMapper.selectList(QueryHelpPlus.getPredicate(Schedule.class, criteria));
    }



}
